package com.aner.test.controller;
import com.aner.tester.controller.BaseControllerTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.aner.tester.utils.text.StringUtils;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;


/**
 * PatchTestControllerTest class
 * 
 * @author aner
 * @date 2020-12-27
 */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
@AutoConfigureMockMvc
public class PatchTestControllerTest extends BaseControllerTest
{

    @Test
    public void testTest() {
        String params = "{'booleanTest':false,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.10228295826462208,'floatTest':0.748201,'intTest':0,'longTest':0,'stringTest':'狗第猫'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.patch("/test/", jsonStr);
        
    }
    @Test
    public void testRequestBodyMapTest() {
        String params = "{'尔小':'03','公0个省':'36','2的狗故4':'43'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.patchBody("/testRequestBodyMap/", jsonStr);
        
    }
    @Test
    public void testRequestBodyListTest() {
        String params = "['4三个小','5安','猪猪公司个东','狗3','猪省','小第的1第4']";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.patchBody("/testRequestBodyList/", jsonStr);
        
    }
    @Test
    public void testRequestBodyLongTest() {
        String params = "0";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.patchBody("/testRequestBodyLong/", jsonStr);
        
    }
    @Test
    public void testRequestParamListTest() {
        String params = "{'testList':['事个小的','小1四广5','的小','2的猪猫']}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.patch("/testRequestParamList/", jsonStr);
        
    }
    @Test
    public void testRequestParamDateTest() {
        String params = "{'testDate':'2020-12-27 21:28:36'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.patch("/testRequestParamDate/", jsonStr);
        
    }
    @Test
    public void testRequestBodyDateTest() {
        String params = "1609075716160";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.patchBody("/testRequestBodyDate/", jsonStr);
        
    }
    @Test
    public void testDateTest() {
        String params = "{'test':'2020-12-27 21:28:36'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.patch("/testDate/", jsonStr);
        
    }
    @Test
    public void testBodyTest() {
        String params = "{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-27 21:28:36','doubleTest':0.5637891423831509,'floatTest':0.45025027,'intTest':0,'longTest':0,'strArray':['狗22故','5故','2小事小'],'stringList':['猪四4安0小','尔三','尔广'],'stringTest':'3猪小小','testObjectArray':[{'booleanTest':false,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.01982428228728894,'floatTest':0.20798618,'intTest':0,'longTest':1,'stringTest':'4东'},{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.8914694192860773,'floatTest':0.8154366,'intTest':1,'longTest':3,'stringTest':'故广2'},{'booleanTest':false,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.9928782506067537,'floatTest':0.7817203,'intTest':0,'longTest':0,'stringTest':'猫0猫猫猫三'}],'testObjectList':[{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-27 21:28:36','doubleTest':0.6265711847442849,'floatTest':0.9125516,'intTest':1,'longTest':3,'stringTest':'猪1'},{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-27 21:28:36','doubleTest':0.4898502145638971,'floatTest':0.6310283,'intTest':1,'longTest':2,'stringTest':'个尔第'},{'booleanTest':false,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.4558971305036533,'floatTest':0.9932396,'intTest':0,'longTest':2,'stringTest':'司广猫广'},{'booleanTest':false,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.49683027915912714,'floatTest':0.4918179,'intTest':1,'longTest':3,'stringTest':'三三'}],'testObjectMap':{'3小尔':'006','三事故':'079'}}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.patchBody("/testRequestBody/", jsonStr);
        
    }
    @Test
    public void testPathVariableTest() {
        String params = "{'params':['广四个','安第猪狗小','的的东','省小小狗尔','第东东5猫','猫四'],'id':[1,2,3]}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.patch("/testPathVariable/{params}/{id}", jsonStr);
        
    }
}
